import axios from 'axios';
import requestFilter from './request_filter';

export default () => {
	// Resquest Interceptors
	axios.interceptors.request.use(request => requestFilter(request));
	// Response Interceptors
	axios.interceptors.response.use(
		(res) => {
			if (res.data.state && Number(res.data.state) !== 200) {
				return Promise.reject(res.data);
			}
			return res.data;
		},
		error => Promise.reject(error.response.data),
	);
};
